package edu.hit.irlab.coref.features.pair;

import java.util.List;

import nlpeap.ml.FeatureDescription;
import nlpeap.ml.FeatureType;

import edu.hit.irlab.coref.PairFeatureExtractor;
import edu.hit.irlab.coref.PairInstance;

/**
 * The distance feature of the two <i>Mentions</i><br>
 * In our system, the distance has only two values, 1 or 2,
 * if the Antecedent is the first Mention that with the same
 * semantic type of the Anaphor before or After the Anaphor, 
 * then the distance value is 1, otherwise 2. This feature will
 * be modified when resolving, here the value is just the distance
 * of the two mentions(the number of mentions that between them)
 * 
 * @author chuter
 *
 */
public class FE_MentionDis implements PairFeatureExtractor {
	public static final FeatureDescription<Integer> FD_IS_MEN_DIST=
        new FeatureDescription<Integer>(FeatureType.FT_SCALAR, "MentionDis");
     
    public void describeFeatures(List<FeatureDescription> fds) {
        fds.add(FD_IS_MEN_DIST);        
    }

    public void extractFeatures(PairInstance inst) {
        inst.setFeature(FD_IS_MEN_DIST, getSentDist(inst));
    }
    
    public Integer getSentDist(PairInstance inst)
    {
    	return Math.abs(inst.getAnaphor().mention_index
    			-inst.getAntecedent().mention_index);
    }
}
